<template>
	<view class="apps">
		<view class="banner">
			<image :src="info" style="width: 100%;height: auto;" mode="widthFix"></image>
		</view>
		<uv-tabbar value="0">
			<view class="tabitem blue" @click="baocun()">
				保存图片
			</view>
		</uv-tabbar>
	</view>
</template>

<script>
	let app;
	import * as ww from '@wecom/jssdk'
	export default {
		data() {
			return {
				id:0,
				info:'',
			}
		},
		onLoad(opt){
			
			app = this;
			app.id = opt.id;
			ww.register({
				corpId: 'ww5d7b19c3c1ce8e1f',    // 必填，当前用户企业所属企业ID
				jsApiList: ['hideMenuItems','createWWLoginPanel',''],  
				agentId:'1000007',
				getConfigSignature: async function(){
				  const configData = await app.request({
						url: '/auth',
						data:{'agent_id':''}
					})
					//app.alert(JSON.stringify(configData));
					return configData.data;
				},                
				getAgentConfigSignature: async function(){
					const AgentConf = await app.request({
						url: '/auth',
						data:{'agent_id':'1000008'}
					})
					//app.alert(JSON.stringify(AgentConf));
					return AgentConf.data;
				}
			})
			ww.hideAllNonBaseMenuItem();
			ww.hideOptionMenu();
			app.qrcode()
		},
		methods: {
			qrcode(){
				app.request({
					url:"/qrcode",
					data:{id:app.id},
					success:function(rlt){
						app.info = rlt.data;
					}
				})
			},
			baocun(){
				const link = document.createElement('a');
				  link.href = app.info;
				  link.setAttribute('download',Math.round(10000)+'.jpg');
				  link.style.display = 'none';
				  document.body.appendChild(link);
				  link.click();
				  document.body.removeChild(link);
			}
		}
	}
</script>


<style scoped>
	.banner{width:100%;height:100vh;}
	.tabitem{display: flex; flex:1;align-items: center; justify-content: center; font-size: 28rpx;color:#fff;font-weight: 400;}
	.blue{background-color:#4f83fe}
</style>
